<link href="/theme/Default/css/stalls/stallsPosting.css" rel="stylesheet">
<script src="/theme/Default/js/jquery.validate.js"></script>
<script src="/js/libnumber.js"></script>
<script src="/js/stallsPosting/indexValidate.js"></script>
<form action="/stallsPosting/edit/<?php echo $product['product_id']?>" method="post" id="stallsPosting">
	<div id="stalls-posting">
		<div class="posting_header">
			Nội dung Sản Phẩm <span class="posting_notice">(Vui lòng điền đầy đủ thông tin)</span>
		</div>
		<div class="posting_row">
			<div class="posting_label">
				Tên Shop :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<label>Tên Shop</label>
				</div>
			</div>
		</div>

		<div class="posting_row">
			<div class="posting_label">
				Chuyên mục :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<select class="form-control" data-size="8" name="data[category_id]" id="data_category_id">
						<option value="0">Chọn danh mục</option>
					    <?php
						    foreach ($rootCategories as $item){?>
								<optgroup value="<?php echo $item['rootId']?>_" label="<?php echo $item['rootName']?>">
								<?php
								foreach ($item['shopCat'] as $cat){?>
									<option value="<?php echo $cat['catId']?>" <?php echo $product['category_id']==$cat['catId']? "selected":""; ?> ><?php echo $cat['category_name']?></option>
								<?php	
								}?>
								</optgroup>
								<?php
						    }
						?>
				  	</select>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Bạn chưa chọn danh mục của tin</span>
			    	</div>
				</div>
			</div>
		</div>
		
		<div class="posting_row">
			<div class="posting_label">
				Tiêu đề :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input placeholder="Dùng tiếng việt có dấu" class="form-control" id="data_product_name" name="data[product_name]" type="text" maxlength="50"  value="<?php echo $product['product_name']?>"/>
				</div>
				<div class="category_group_warntip hide" style="display: none;">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Tiêu đề phải dài ít nhất 2 ký tự</span>
			    	</div>
				</div>
			</div>
		</div>
	
		<div class="posting_row">
			<div class="posting_label">
				Giá :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input placeholder="Giá bạn muốn bán" class="form-control" name="data[price]" type="text" value="<?php echo $product['price']?>" id="data_price" maxlength="15" data-v-max="999999999999" data-v-min="0" data-a-dec="."  data-a-sep=","/>
				</div>
				<div class="element-inline color-defaul">
					<label class="radio-inline">
					  	<input type="radio" name="data[currency_type]" id="radioCurrencyVnd" value="1" <?php echo $product['currency_type'] ==1?"checked":""; ?>> VND
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[currency_type]" id="radioCurrencyUsd" value="2" <?php echo $product['currency_type'] ==2?"checked":""; ?>> USD
					</label>
				</div>
				<div class="category_group_warntip hide warn-price">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Thiếu giá tiền, vui lòng nhập số</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row">
			<div class="posting_label label-top">
				Hình :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<div class="element-images">
						<div class="images-tip">“Trăm nghe không bằng mắt thấy”. Tin có hình được xem nhiều gấp 7 lần. 
							<br><b>ĐĂNG HÌNH ĐỂ BÁN CHẠY HƠN!</b>
						</div>
						<div class="row-3-image">
							<?php for ($i = 0; $i<6; $i++){?>
								<div class="one-image">
									<input class="postImage img<?php echo ($i+1)?>" type="file"/>
									<div class="image-upload">
										<span>Đăng hình</span>
									</div>
									<div id="image-success-<?php echo ($i+1)?>" class="image-up-success" style="<?php echo empty($img[$i])?"display: none":"" ?>">
										<img src="/<?php echo !empty($img[$i])? $img[$i]['Image']['url'] :"" ?>"/>
										<div class="remove-image delete<?php echo ($i+1)?>"></div>
									</div>
								</div>
							<?php if ($i==2){
								echo "</div><div class='row-3-image'>";
							} }?>
					</div>
				</div>
				<div class="category_group_warntip warn-image hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy chọn ít nhất 1 hình</span>
			    	</div>
				</div>
			</div>
		</div>
	</div>

		<div class="posting_row">
			<div class="posting_label">
				Hãng sản xuất :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[manufacturer]" type="text" value="<?php echo $product['manufacturer']; ?>" id="data_manufacturer" maxlength="100"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập hãng sản xuất</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row">
			<div class="posting_label">
				Model :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[model]" type="text" value="<?php echo $product['model']; ?>" id="data_model" maxlength="100"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập model</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row">
			<div class="posting_label">
				Năm sản xuất :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[product_year]" type="text" value="<?php echo $product['product_year']; ?>" id="data_product_year" maxlength="4"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập năm sản xuất</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row">
			<div class="posting_label">
				Tình trạng :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<label class="radio-inline">
					  	<input type="radio" name="data[product_status]" id="radioNew" value="2" <?php echo $product['product_status']==2? "checked":""; ?>> Mới 100%
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[product_status]" id="radioOld" value="1" <?php echo $product['product_status']==1? "checked":""; ?>> Đã qua sử dụng
					</label>
				</div>
				<div class="category_group_warntip">
					
				</div>
			</div>
		</div>
		
		<div class="posting_row">
			<div class="posting_label">
				Loại sản phẩm :
			</div>
			<div class="posting_element typeProduct">
				<div class="element-main">
					<label class="checkbox-inline">
					  	<input type="checkbox" name="data[best_sell]" id="best_sell" value="2" <?php echo $product['best_sell']==2? "checked":""; ?>> Sản phẩm bán chạy
					</label>
					<label class="checkbox-inline">
					  	<input type="checkbox" name="data[product_new]" id="product_new" value="1" <?php echo $product['product_new']==1? "checked":""; ?>> Sản phẩm mới nhất
					</label>
				</div>
				<div class="category_group_warntip hide warn-time">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy chọn loại sản phẩm</span>
			    	</div>
				</div>
			</div>
		</div>
		
		<div class="posting_row">
			<div class="posting_label">
				Cung cấp :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<label class="radio-inline">
					  	<input type="radio" name="data[provide]" id="radioProvide" value="1" <?php echo $product['provide']==1? "checked":""; ?>> Sản phẩm đang cung cấp
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[provide]" id="radioWarehouse" value="2" <?php echo $product['provide']==2? "checked":""; ?>> Sản phẩm có tại kho bãi
					</label>
				</div>
				<div class="category_group_warntip">
					
				</div>
			</div>
		</div>
		
		<div class="posting_row">
			<div class="posting_label">
				Thời gian đã hoạt động :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[time_used]" type="text" value="<?php echo $product['time_used'];?>" id="data_time_used" maxlength="4"/>
				</div>
				<div class="element-inline color-defaul">
					<label class="radio-inline">
					  	<input type="radio" name="data[time_used_type]" id="radioTimeYear" value="1"  <?php echo $product['time_used_type']==1? "checked":""; ?>> Năm
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[time_used_type]" id="radioTimeHour" value="2" <?php echo $product['time_used_type']==2? "checked":""; ?>> Giờ
					</label>
				</div>
				<div class="category_group_warntip hide warn-time">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập thời gian đã hoạt động</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row forklift">
			<div class="posting_label">
				Tải trọng làm việc (kg/m3) :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[work_weight]" type="text" value="<?php echo $product['work_weight'] ;?>" id="data_work_weight" maxlength="12"/>
				</div>
				<div class="element-inline color-defaul">
					<label class="radio-inline">
					  	<input type="radio" name="data[time_used_type]" id="radioTimeYear" value="2"
					  	<?php echo $product['time_used_type']==2?"checked":"";?>
					  	> Kg
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[time_used_type]" id="radioTimeHour" value="1"
					  	<?php echo $product['time_used_type']==1?"checked":"";?>
					  	> m3
					</label>
				</div>
				<div class="category_group_warntip hide warn-time">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập tải trọng làm việc</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row forklift">
			<div class="posting_label">
				Chiều cao (mét) :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[height]" type="text" value="<?php echo $product['height'] ;?>" id="data_height" maxlength="12"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập chiều cao</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row forklift">
			<div class="posting_label">
				Tải trọng riêng (kg) :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<input class="form-control" name="data[weight]" type="text" value="<?php echo $product['weight'] ;?>" id="data_weight" maxlength="12"/>
				</div>
				<div class="category_group_warntip hide">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập tải trọng riêng</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row forklift">
			<div class="posting_label">
				Loại vỏ/bánh :
			</div>
			<div class="posting_element">
				<div class="element-main type_wheel">
					<label class="radio-inline">
					  	<input type="radio" name="data[wheel_type]" id="data_wheel_type1" value="1" <?php echo $product['wheel_type'] ==1 ?"checked":"";?>> Vỏ đặc
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[wheel_type]" id="data_wheel_type2" value="2" <?php echo $product['wheel_type'] ==2 ?"checked":"";?>> Vỏ hơi
					</label>
					<label class="radio-inline">
					  	<input type="radio" name="data[wheel_type]" id="data_wheel_type3" value="3" <?php echo $product['wheel_type'] ==3 ?"checked":"";?>> Bánh xích
					</label>
				</div>
				<div class="category_group_warntip">
					
				</div>
			</div>
		</div>

		<div class="posting_row forklift">
			<div class="posting_label">
				Option :
			</div>
			<?php
				$selected = 0;
				$test =  ctype_digit(strval($product['option']));
				if($test){
					$selected = $product['option'];
				}
			?>
			<div class="posting_element">
				<div class="element-main">
					<select class="form-control" name="data[option1]" id="data_option1" style="margin-bottom: 10px;">
						<option value="0" <?php echo $selected==0?"selected":""; ?>>Khác ...</option>
						<option value="1" <?php echo $selected==1?"selected":""; ?>>Side shifter</option>
						<option value="2" <?php echo $selected==2?"selected":""; ?>>Fork Positioner</option>
						<option value="3" <?php echo $selected==3?"selected":""; ?>>Rotating Fork</option>
						<option value="4" <?php echo $selected==4?"selected":""; ?>>Hinged Fork</option>
						<option value="5" <?php echo $selected==5?"selected":""; ?>>Bale Clamp</option>
						<option value="6" <?php echo $selected==6?"selected":""; ?>>Roll Clamp</option>
						
					</select>
					<input class="form-control" name="data[option2]" <?php echo $selected==0?'':'disabled'?> type="text" 
						value="<?php echo $test?"" : $product['option']?>" id="data_option2" maxlength="150"/>
				</div>
				<div class="category_group_warntip hide" style="margin-top: 40px;">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập option</span>
			    	</div>
				</div>
			</div>
		</div>
		<div class="posting_row">
			<div class="posting_label">
				Option :
			</div>
			<div class="posting_element">
				<div class="element-main">
					<textarea rows="5" class="form-control" name="data[content]" id="data_content"><?php echo $product['content'];?></textarea>
				</div>
				<div class="category_group_warntip hide" style="margin-top: 40px;">
					<div class="warntip_triangle">&nbsp;</div>
					<div class="warntip_content">
						<span>Hãy nhập option</span>
			    	</div>
				</div>
			</div>
		</div>

		<div class="posting_row">
			<div class="posting_label">
				
			</div>
			<div class="posting_element">
				<?php for($i=0; $i<6; $i++){
					if(empty($img[$i])){
						echo "<input type='hidden' class='img_".($i+1)." hdImg' name='data[img][".$i."][url]'/>";
					}
					else{
						echo "<input type='hidden' class='img_".($i+1)." hdImg' name='data[img][".$i."][url]' value='".$img[$i]['Image']['url']."'/>";
						echo "<input type='hidden' name='data[img][".$i."][id]' value='".$img[$i]['Image']['id']."'/>";
					}
				 }?>
				<div class="element-main">
					<button type="submit" class="btn btn-danger">Sửa sản phẩm</button>
				</div>
			</div>
		</div>
		<div>
			
		</div>
	</div>
</form>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">Thông báo</h4>
      </div>
      <div class="modal-body">
       
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-primary" data-dismiss="modal">Đóng</button>
        <!-- <button type="button" class="btn btn-primary">Save changes</button> -->
      </div>
    </div>
  </div>
</div>
